﻿@using System.Web.Mvc.Html
@using SimpleScrum.Core.Entities
@using SimpleScrum.Helpers
@using SimpleScrum.Utils
@model SimpleScrum.Areas.Scrum.Models.UserStorySprintModel
@{
    ViewBag.Title = "All BackLogs";
}
<div class="breadcrumbs" id="breadcrumbs">
    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="@Url.Action("Index","DashBoard")">Home</a>
            <span class="divider">
                <i class="icon-angle-right arrow-icon"></i>
            </span>
        </li>
        <li>
            <a href="@Url.Action("Details", "Project", new {projectId=@Client.Instance.CurrentProjectId})">Project</a>
            <span class="divider">
                <i class="icon-angle-right arrow-icon"></i>
            </span>
        </li>
        <li class="active">BackLogs</li>
    </ul>
    <div class="nav-search pull-right">
        @*<a class="btn btn-small btn-success" href="@Url.Action("New","BackLog")">
            <i class="icon-plus-sign-alt"></i> New BackLog
        </a>*@
    </div>
</div>
<div class="page-content">
    <div class="page-header position-relative">
        <h1>@ViewBag.Title<small><i class="icon-double-angle-right"></i>@ViewBag.Message</small></h1>
    </div><!--/.page-header-->
    @if (Model.UserStoryList.Count().CompareTo(0) == 0 || Model.SprintList.Count().CompareTo(0) == 0)
    {
        <div class="row-fluid">
            <div class=" span10 offset1 text-center">
                <h1 class="text-error">You project's don't have any Backlog!</h1>
                <h2 class="text-success">Create Your First project's User Story or Sprint</h2>
                @if (Model.UserStoryList.Count().CompareTo(0) == 0){
                    <a class="btn btn-app btn-success" href="@Url.Action("New", "UserStory")">
                        <i class="icon-plus-sign-alt"></i> New<br/>User Story
                    </a>
                }
                @if (Model.SprintList.Count().CompareTo(0) == 0)
                {
                    <a class="btn btn-app btn-success" href="@Url.Action("New", "Sprint")">
                        <i class="icon-plus-sign-alt"></i> New<br/>Sprint
                    </a>
                }
            </div>
        </div>
    }
    else
    {
        <div class="row-fluid">
            <div class="table-header">Results for "Latest Registered BackLogs"</div>
            <div id="sample-table-2_wrapper" class="dataTables_wrapper" role="grid">
                <div class="row-fluid">
                    <div class="span6">
                        <div id="sample-table-2_length" class="dataTables_length">
                            <label>
                                Display
                                <select size="1" name="sample-table-2_length" aria-controls="sample-table-2">
                                    <option value="10" selected="selected">10</option>
                                    <option value="25">25</option>
                                    <option value="50">50</option>
                                    <option value="100">100</option>
                                </select>
                                records
                            </label>
                        </div>
                    </div>
                    <div class="span6">
                        <div class="dataTables_filter" id="sample-table-2_filter">
                            <label>
                                Search:
                                <input type="text" aria-controls="sample-table-2"/>
                            </label>
                        </div>
                    </div>
                </div>
                <table id="sample-table-2" class="table table-striped table-bordered table-hover dataTable " aria-describedby="sample-table-2_info">
                    <thead>
                        <tr role="row">
                            <th class="center sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label=" " style="width: 20px;">
                                <label><input type="checkbox" /><span class="lbl"></span></label>
                            </th>
                            <th class="sorting" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending" style="width: 200px;">
                                Name
                            </th>
                            <th class="sorting" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending">
                                Description
                            </th>
                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="" style="width: 80px;"></th>
                        </tr>
                    </thead>
                    <tbody role="alert" aria-live="polite" aria-relevant="all">
                        @foreach (var item in Model.BackLogList)
                        {
                            <tr>
                                <td class="center sorting_1"><label><input type="checkbox" /><span class="lbl"></span></label></td>
                                <td>@Html.ActionLink(item.Title, "Details", new {id = item.Id})</td>
                                <td>@Html.DisplayFor(modelItem => item.AssignDate)</td>
                                <td class="td-actions">
                                    <div class="hidden-phone visible-desktop action-buttons">
                                        <a class="blue" href="@Url.Action("Details", "BackLog", new {id = item.Id})">
                                            <i class="icon-zoom-in bigger-130"></i>
                                        </a>
                                        <a class="green" href="@Url.Action("Edit", "BackLog", new {id = item.Id})">
                                            <i class="icon-pencil bigger-130"></i>
                                        </a>
                                        <a class="red" href="@Url.Action("Delete", "BackLog", new {id = item.Id})">
                                            <i class="icon-trash bigger-130"></i>
                                        </a>
                                    </div>
                                    <div class="hidden-desktop visible-phone">
                                        <div class="inline position-relative">
                                            <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown">
                                                <i class="icon-caret-down icon-only bigger-120"></i>
                                            </button>
                                            <ul class="dropdown-menu dropdown-icon-only dropdown-yellow pull-right dropdown-caret dropdown-close">
                                                <li>
                                                    <a href="@Url.Action("Details", "BackLog", new {id = item.Id})" class="tooltip-info" data-rel="tooltip" title="View">
                                                        <span class="blue"><i class="icon-zoom-in bigger-120"></i></span>
                                                    </a>
                                                </li>
                                                <li>
                                                    <a href="@Url.Action("Edit", "BackLog", new {id = item.Id})" class="tooltip-success" data-rel="tooltip" title="Edit">
                                                        <span class="green"><i class="icon-edit bigger-120"></i></span>
                                                    </a>
                                                </li>
                                                <li>
                                                    <a href="@Url.Action("Delete", "BackLog", new {id = item.Id})" class="tooltip-error" data-rel="tooltip" title="Delete">
                                                        <span class="red"><i class="icon-trash bigger-120"></i></span>
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>

                <div class="row-fluid">
                    <div class="span5">
                        <div class="table-header"> @SelectExtensions.DropDownListFor(Html, model => model.UserStoryList, new SelectList(EnumHelper.GetEnumInfo(typeof (UserStory.StatusEnum)), "ID", "Name"))</div>
                        <table id="sample-table-2" class="table table-striped table-bordered table-hover dataTable" aria-describedby="sample-table-2_info">
                            <thead>
                                <tr role="row">
                                    <th class="center sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label=" " style="width: 20px;">
                                        <label><input type="checkbox" /><span class="lbl"></span></label>
                                    </th>
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending" style="width: 200px;">
                                        Name
                                    </th>
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending">
                                        Description
                                    </th>
                                    <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="" style="width: 80px;"></th>
                                </tr>
                            </thead>
                            <tbody role="alert" aria-live="polite" aria-relevant="all">
                                @foreach (var item in Model.UserStoryList)
                                {
                                    <tr>
                                        <td class="center sorting_1"><label><input type="checkbox"  id="@item.Title"/><span class="lbl"></span></label></td>
                                        <td>@Html.ActionLink(item.Title, "Details", new {id = item.Id})</td>
                                        <td>@Html.DisplayFor(modelItem => item.Details)</td>
                                   
                                    </tr>
                                }
                            </tbody>
                        </table>
                    </div>
                    <div class="span2">
                        @*@Html.ActionLink("Add", "Details", new {   id=item.Id   })*@
                    
                    </div>
                    <div class="span5">
                        <div class="table-header"> @*@SelectExtensions.DropDownListFor(Html, model => model.SprintList, new SelectList(EnumHelper.GetEnumInfo(typeof(UserStory.)), "ID", "Name"))*@</div>
                        <table id="sample-table-2" class="table table-striped table-bordered table-hover dataTable" aria-describedby="sample-table-2_info">
                            <thead>
                                <tr role="row">
                                    <th class="center sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label=" " style="width: 20px;">
                                        <label><input type="checkbox" /><span class="lbl"></span></label>
                                    </th>
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending" style="width: 200px;">
                                        Name
                                    </th>
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending">
                                        Description
                                    </th>
                                    <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="" style="width: 80px;"></th>
                                </tr>
                            </thead>
                            <tbody role="alert" aria-live="polite" aria-relevant="all">
                                @foreach (var item in Model.SprintList)
                                {
                                    <tr>
                                        <td class="center sorting_1"><label><input type="checkbox" /><span class="lbl"></span></label></td>
                                        <td>@Html.ActionLink(item.Name, "Details", new {id = item.Id})</td>
                                        <td>@Html.DisplayFor(modelItem => item.Description)</td>
                                   
                                    </tr>
                                }
                            </tbody>
                        </table>
                    </div>
                </div>
            
                <div class="row-fluid">
                    <div class="span6">
                        <div class="dataTables_info" id="sample-table-2_info">Showing 1 to 10 of 23 entries</div>
                    </div>
                    <div class="span6">
                        <div class="dataTables_paginate paging_bootstrap pagination">
                            @*<ul>
                        <li class="prev disabled">
                            <a href="#">
                                <i class="icon-double-angle-left"/>
                            </a>
                        </li>
                        <li class="active">
                            <a href="#">1</a>
                        </li>
                        <li>
                            <a href="#">2</a>
                        </li>
                        <li>
                            <a href="#">3</a>
                        </li>
                        <li class="next">
                            <a href="#"></a>
                        </li>
                    </ul>*@
                        </div>
                    </div>
                </div>
            </div>
        </div>
    }
</div>

<!--page specific plugin scripts-->
<script type="text/javascript">
    $(function () {
        var oTable1 = $('#sample-table-2').dataTable({
            "aoColumns": [
                { "bSortable": false },
                null, null, null, null, null,
                { "bSortable": false }
            ]
        });
        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });
        });
        $('[data-rel="tooltip"]').tooltip({ placement: tooltip_placement });
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table');
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })
</script>